/*
 * Copyright (c) 2020, 2023, 3044483124@qq.com All rights reserved.
 *
 */
package cn.itcast;

import java.util.Random;

/**
 * <p>Project: JavaStudy - For5
 * <p>Powered by jiangbo On 2023-02-25
 * 14:39:49
 * <p>Created by IntelliJ IDEA
 *
 * @author jiangbo [3044483124@qq.com]
 * @version 1.0
 * @since 8/17
 */
public class For5 {
    public static void main(String[] args) {
        var rand = new Random();
        int num = rand.nextInt(10, 50);
        //int num=15;
        System.out.println(num);
        int sp = num;
        for (int i = 1; i < num; i += 2) {
            --sp;
//输出空格
            for (int j = 1; j <= sp; j++) {
                System.out.print(" ");
            }
            for (int n = 1; n <= i; n++) {
                System.out.printf("\033[%dm*\033[0m", rand.nextInt(31, 38));
            }
            System.out.println();
        }
        for (int i = num % 2 == 0 ? num - 3 : num - 4; i >= 1; i -= 2) {
            ++sp;
//输出空格
            for (int j = 1; j <= sp; j++) {
                System.out.print(" ");
            }
            for (int n = 1; n <= i; n++) {
                System.out.printf("\033[%dm*\033[0m", rand.nextInt(31, 38));
            }
            System.out.println();
        }
        }

}



